﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WpfApp1
{
    internal class TestManager
    {
        private static TestManager instance;
        public static TestManager Instance
        {
            get
            {
                if (instance == null)
                    instance = new TestManager();
                return instance;
            }
        }
        public List<Test> TestList { get; set; }
        public TestManager()
        {

            TestList = new List<Test>();

            TestList.Add(new Test() { Id = 1, Name = "a" });
            TestList.Add(new Test() { Id = 2, Name = "b" });
            TestList.Add(new Test() { Id = 3, Name = "c" });
            TestList.Add(new Test() { Id = 4, Name = "3" });
            TestList.Add(new Test() { Id = 5, Name = "4" });
            TestList.Add(new Test() { Id = 6, Name = "7" });
            TestList.Add(new Test() { Id = 7, Name = "8" });
            TestList.Add(new Test() { Id = 8, Name = "88" });
            TestList.Add(new Test() { Id = 11, Name = "11" });
            TestList.Add(new Test() { Id = 12, Name = "12" });
            TestList.Add(new Test() { Id = 13, Name = "13" });
            TestList.Add(new Test() { Id = 14, Name = "14" });
            TestList.Add(new Test() { Id = 15, Name = "15" });
            TestList.Add(new Test() { Id = 16, Name = "16" });
            TestList.Add(new Test() { Id = 17, Name = "17" });
            TestList.Add(new Test() { Id = 18, Name = "18" });
            TestList.Add(new Test() { Id = 19, Name = "19" });
            TestList.Add(new Test() { Id = 20, Name = "20" });
        }

        public void Start()
        {
            Task.Run(() =>
            {
                int index = 0;
                while (true)
                {
                    foreach (var item in TestList)
                    {
                        item.Name = index + "";
                        index++;

                        //EventMgrLib.EventMgr.Ins.GetEvent<TestDataPubsub>().Publish(item);
                        Task.Delay(1000).Wait();
                    }
                }
            });
        }
    }
}
